
import utils.util as util
import json
import time 
from push.push import push

def get_weather_data():
    location = '120.11,30.31'
    key = '0ee8a4c46b304f2bb758e57f5b55024a'
    url = 'https://devapi.qweather.com/v7/weather/3d?location=%s&key=%s'%(location,key)
    response = util.requests_get(url)

    if util.check_response_is_ok(response):
        day_result = json.loads(response.text)['daily'][0]
        title = '今天是：'+day_result['fxDate']+' '+util.weekday()

        format_data = '最高温度：'+day_result['tempMax']+'℃\n'\
            '最低温度：'+day_result['tempMin']+'℃\n'\
            '白天天气：'+day_result['textDay']+'\n'\
            '晚间天气：'+day_result['textNight']+'\n'\
            ''
        return title, format_data


def send_weather_to_feishu():
    title,content = get_weather_data()
    push.feishu_push(title=title,send_content=content,template="turquoise")
